package com.weaver.seconddev.tl.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * @author yukun.yan
 * @description DateUtils 日期格式类
 * @date 2022/12/6 17:05
 */
public class DateUtils {

    private static final LocalDate localDate = LocalDate.now();

    private static final LocalTime localTime = LocalTime.now();
    private static final LocalDateTime localDateTime = LocalDateTime.now();
    // 日期格式化
    public static final String YYYY_DD_MM_FORMAT = "yyyy-MM-dd";

    public static final String HH_MM_SS_FORMAT = "HH:mm:ss";

    public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    /**
     * 获取当前时间的年月日
     * 格式 2022-12-06
     *
     * @return
     */
    public static String getLocalDate() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(YYYY_DD_MM_FORMAT);
        return LocalDate.now().format(dateTimeFormatter);
    }

    /**
     * 获取当前时分秒
     * 格式 17:13:37
     *
     * @return
     */
    public static String getLocalTime() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(HH_MM_SS_FORMAT);
        return LocalTime.now().format(dateTimeFormatter);
    }

    /**
     * 获取当前时间的年月日
     * 格式 2022-12-06
     *
     * @return
     */
    public static String getLocalDateTime() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT);
        return LocalDateTime.now().format(dateTimeFormatter);
    }
}
